package com.xiaoshi.config;

import com.xiaoshi.hander.ResAccessDeniedHandler;
import com.xiaoshi.hander.ResAuthExceptionEntryPoint;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.web.ErrorProperties;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;
import java.util.stream.Collectors;
/**
 * 处理资源服务器异常
 */
@Configuration
public class ResAuthExceptionConfigure  {

    @Bean
    @ConditionalOnMissingBean(name = "accessDeniedHandler")  //当IOC容器中没有指定名称或类型的Bean的时候，就注册它
    public ResAccessDeniedHandler accessDeniedHandler() {
        return new ResAccessDeniedHandler();
    }

    @Bean
    @ConditionalOnMissingBean(name = "authenticationEntryPoint")
    public ResAuthExceptionEntryPoint authenticationEntryPoint() {
        return new ResAuthExceptionEntryPoint();
    }


}